const getAreaObj = (parentPath, regionGrade, administrationId) => {
	const areaObj = {
		authProvince: '',
		authCity: '',
		authArea: '',
		authStreet: '',
		authCommunity: '',
	}
	if (parentPath) {
		const areaData = parentPath.split(',')
		for (let index = 0; index < regionGrade; index++) {
			let key = Object.keys(areaObj)[index]
			areaObj[key] = areaData[index] || administrationId
		}
	}
	return areaObj
}

export const areaEditFormConfig = (model: any) => {
	const areaObj = getAreaObj(model.parentPath, model.regionGrade, model.administrationId)
	const paramsObj = {
		administrationOrganizationId: model.administrationId,
		classifyId: 3,
		...areaObj,
	}

	return {
		label: '地区信息',
		inline: false,
		showBtn: true,
		showReset: false,
		labelPosition: 'right',
		labelWidth: '170px',
		column: [
			{
				label: '行政区划名称',
				prop: 'administrationNameTag',
				type: 'input',
				span: 24,
				readonly: true,
				// rules: [{ required: true, message: '请输入行政区划名称' }],
			},
			{
				label: '上级行政区划',
				prop: 'administrationPidName',
				type: 'input',
				readonly: true,
				span: 24,
				// rules: [{ required: true, message: '请选择上级行政区划' }],
			},
			{
				label: '行政区划排序',
				prop: 'administrationSorting',
				type: 'input',
				tip: '数字越小，排序靠上',
				span: 24,
				readonly: true,
				// rules: [{ required: true, message: '请输入行政区划排序' }],
			},
			{
				label: '本单位行政审批负责人',
				prop: 'approverIds',
				type: 'remoteSelect',
				api: 'sys_user_querypage',
				filterKey: 'userId',
				filterLabel: 'realName',
				multiple: true,
				paramsObj: {
					...paramsObj,
					pageParaPO: {
						size: 1000,
					},
				},
				span: 24,
				rules: [{ required: true, message: '请选择本单位行政审批负责人' }],
			},
		],
	}
}
